---
title: Naming Convention
draft: true
---

Here's how we recommend naming things in your code.

## Structs & custom data types

We give structs and other custom data types *PascalCase* names.

```ts
const Boid = struct({
  pos: vec2f,
  vel: vec2f,
});

const BoidArray = (n: number) => arrayOf(Boid, n);
```


## Functions

We give tgpu functions *camelCase* names, without any special suffix or prefix. Usually imperative mood, verb-phrase structure (i.e., `"doSomething"`).

```ts
const createBoid = tgpu
  .fn([], Boid)(() => ({
    pos: vec2f(),
    vel: vec2f(0, 1),
  }));
```

## Buffers

We give buffers *camelCase* names with a `Buffer` suffix.

```ts
const boidsBuffer = root
  .createBuffer(BoidArray(512))
  .$usage('uniform');
```

## Buffer usages

We give buffer usages *camelCase* names with a suffix that corresponds to their usage.

```ts
const boidsUniform = boidsBuffer.as('uniform');
const boidsMutable = boidsBuffer.as('mutable');
const boidsReadonly = boidsBuffer.as('readonly');
```

## Buffer shorthands

We give buffer shorthands *camelCase* names with no special suffix, since they represent both
the buffer, and the single permitted usage.

```ts
const cells1 = root.createUniform(Cells);
const cells2 = root.createMutable(Cells);
const cells3 = root.createReadonly(Cells);
```

## Slots

We give slots *camelCase* names with the `Slot` suffix.

```ts
const colorSlot = tgpu.slot(vec4f(1, 0, 0, 1));
```

## Accessors

We give accessors *camelCase* names with the `Access` suffix.

```ts
const colorAccess = tgpu['~unstable'].accessor(vec4f);
```

## Derived

We give derived values *camelCase* names, without any special prefix or suffix.

```ts
const lighterColor = tgpu['~unstable'].derived(() => add(color.value, vec4f(0.2, 0.2, 0.2, 0)));
```
